/**
 * 封装操作数据库的通用 API
 */
const mysql = require('mysql');

exports.base = (sql, data, callback) => {
    const connection = mysql.createConnection({
        host: 'localhost',
        user: 'root',
        password: 'root',
        database: 'books'
    });
    connection.connect();
    let query = connection.query(sql, data, (err, results, fields)=>{
        connection.end();
        callback(err, results, fields);
    });
};
